<template>
  <el-container :style="'height:' + fullHeight + 'px;'">
    <el-header>
      <el-row>
        <el-col :span="12">
          <i class="el-icon-s-fold" @click="openMenu"></i>
          <img src="" alt="" />
          <span class="titleYI">
            易理赔
          </span>
        </el-col>
        <el-col :span="12">
          <el-dropdown>
            <el-button class="admin" type="info" round>
              {{ username }}<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="logout()">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-header>
    <el-container>
      <!--            <el-aside width="200px">-->
      <leftMenu></leftMenu>
      <!--            </el-aside>-->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
    <el-footer></el-footer>
  </el-container>
</template>

<script>
import leftMenu from "../components/leftMenu";
import { mapActions } from "vuex";
export default {
  name: "Home",
  components: {
    leftMenu
  },
  methods: {
    ...mapActions(["openMenu"]),
    //注销登录
    logout() {
      this.$confirm("是否注销当前登录?", "提示", {
        confirmButtonText: "注销登录",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          //清空用户信息
          sessionStorage.clear();
          this.$router.replace("/");
          this.$message({
            type: "success",
            message: "注销成功!",
            customClass: "msg",
            duration: 1000,
            center: true
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消！"
          });
        });
    },
    get_bodyHeight() {
      const that = this;
      window.onresize = () => {
        return (() => {
          window.fullHeight = document.documentElement.clientHeight;
          that.fullHeight = window.fullHeight;
        })();
      };
    }
  },
  data() {
    return {
      username: sessionStorage.getItem("username"),
      fullHeight: document.documentElement.clientHeight
    };
  },
  mounted() {
    this.get_bodyHeight();
  },
  watch: {
    //监控浏览器高度变化
    fullHeight(val) {
      if (!this.timer) {
        this.fullHeight = val;
        this.timer = true;
        let that = this;
        setTimeout(function() {
          that.timer = false;
        }, 400);
      }
    }
  }
};
</script>

<style scoped>
.el-header,
.el-footer {
  background-color: rgb(36, 47, 66);
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  height: 826px;
  /* line-height: 160px; */
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-icon-s-fold {
  float: left;
  font-size: 2em;
  margin-top: 14px;
  color: rgb(144, 147, 153);
}
.titleYI {
  float: left;
  margin-left: 10px;
  font-size: 1.3em;
  color: rgb(144, 147, 153);
}
.el-menu {
  border-right: solid 0 !important;
}

.el-scrollbar__thumb {
  display: none;
}
.el-dropdown {
  float: right;
}
.admin {
  padding: 7px 10px !important;
}
.el-message {
  min-width: 200px !important;
}
/deep/ .el-dialog {
  margin-top: 3vh !important;
  width: 30%;
}
</style>
